/*
 * @Author: yixin
 * @Date: 2018-01-25 10:52:16
 * @Last Modified by: yixin
 * @Last Modified time: 2018-06-29 14:32:55
 * 头部公用组件
 */
import React from 'react';
import Icon from 'react-native-vector-icons/icomoon';
import { Text, View } from 'react-native';
import { createStyles } from '../utils/view';
import { colors } from '../styles/basic';

/**
 *
 * @param {*} title 标题文字
 * @param {*} navigator 如果需要返回按钮则传入navigator
 */
const Header = ({ title, navigator }) => {
  return (
    <View style={styles.head}>
      {
        navigator && <Icon onPress={() => navigator.dismissAllModals()} style={styles.back} name="left" />
      }
      <Text style={styles.text}>{title}</Text>
    </View>
  );
};

let styles = {
  head: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    paddingTop: 35,
    height: 135,
    backgroundColor: colors.Red,
  },
  text: {
    color: '#fff',
    fontSize: 36,
    fontWeight: 'bold',
  },
  back: {
    fontSize: 36,
    position: 'absolute',
    left: 30,
    color: '#fff',
    top: 66,
    paddingRight: 50,
  }
};

styles = createStyles(styles);

export default Header;